import {getCapsuleGeometry, getSafeAreaGeometry, getSafeAreaInsets, getStatusBarHeight, unit} from "@/common/util";
import config from "./libs/config/index";

const $u: UInterface = {
    v: config.version,
    version: config.version,
    color: config.color,
    unit: unit,
    getCapsuleGeometry: getCapsuleGeometry,
    getStatusBarHeight: getStatusBarHeight,
    getSafeAreaGeometry: getSafeAreaGeometry,
    getSafeAreaInsets: getSafeAreaInsets
};

// 挂载到uni对象上
Object.defineProperty(uni, "$u", {
    value: $u,
    enumerable: false,
    writable: true,
    configurable: true
});

// 挂载到Vue2和Vue3中
const install = (Vue: any) =>
{
    // #ifdef VUE2
    Vue.prototype.$u = $u;
    // #endif

    // #ifdef VUE3
    Vue.config.globalProperties.$u = $u;
    // #endif
};

export default {
    install
};